﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IndustrialSmokeCalc
{
    [Table]
    public class MeasurementDB : INotifyPropertyChanged, INotifyPropertyChanging
    {
        private int _measurementId;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false,
            AutoSync = AutoSync.OnInsert)]
        public int MeasurementId
        {
            get
            {
                return _measurementId;
            }
            set
            {
                if (_measurementId != value)
                {
                    NotifyPropertyChanging("MeasurementId");
                    _measurementId = value;
                    NotifyPropertyChanged("MeasurementId");
                }
            }
        }

        private string _chimneyId;
        [Column]
        public string ChimneyId
        {
            get
            {
                return _chimneyId;
            }
            set
            {
                if (_chimneyId != value)
                {
                    NotifyPropertyChanging("ChimneyId");
                    _chimneyId = value;
                    NotifyPropertyChanged("ChimneyId");
                }
            }
        }

        private string _userId;
        [Column]
        public string UserId
        {
            get
            {
                return _userId;
            }
            set
            {
                if (_userId != value)
                {
                    NotifyPropertyChanging("UserId");
                    _userId = value;
                    NotifyPropertyChanged("UserId");
                }
            }
        }

        private string _measurementObserver;
        [Column]
        public string MeasurementObserver
        {
            get
            {
                return _measurementObserver;
            }
            set
            {
                if (_measurementObserver != value)
                {
                    NotifyPropertyChanging("MeasurementObserver");
                    _measurementObserver = value;
                    NotifyPropertyChanged("MeasurementObserver");
                }
            }
        }

        private string _measurementDate;
        [Column]
        public string MeasurementDate
        {
            get
            {
                return _measurementDate;
            }
            set
            {
                if (_measurementDate != value)
                {
                    NotifyPropertyChanging("MeasurementDate");
                    _measurementDate = value;
                    NotifyPropertyChanged("MeasurementDate");
                }
            }
        }

        private string _measurementTime1;
        [Column]
        public string MeasurementTime1
        {
            get
            {
                return _measurementTime1;
            }
            set
            {
                if (_measurementTime1 != value)
                {
                    NotifyPropertyChanging("MeasurementTime1");
                    _measurementTime1 = value;
                    NotifyPropertyChanged("MeasurementTime1");
                }
            }
        }

        private string _measurementTime2;
        [Column]
        public string MeasurementTime2
        {
            get
            {
                return _measurementTime2;
            }
            set
            {
                if (_measurementTime2 != value)
                {
                    NotifyPropertyChanging("MeasurementTime2");
                    _measurementTime2 = value;
                    NotifyPropertyChanged("MeasurementTime2");
                }
            }
        }

        private string _measurementResultRingelmann;
        [Column]
        public string MeasurementResultRingelmann
        {
            get
            {
                return _measurementResultRingelmann;
            }
            set
            {
                if (_measurementResultRingelmann != value)
                {
                    NotifyPropertyChanging("MeasurementResultRingelmann");
                    _measurementResultRingelmann = value;
                    NotifyPropertyChanged("MeasurementResultRingelmann");
                }
            }
        }

        private string _measurementUnitAddr;
        [Column]
        public string MeasurementUnitAddr
        {
            get
            {
                return _measurementUnitAddr;
            }
            set
            {
                if (_measurementUnitAddr != value)
                {
                    NotifyPropertyChanging("MeasurementUnitAddr");
                    _measurementUnitAddr = value;
                    NotifyPropertyChanged("MeasurementUnitAddr");
                }
            }
        }

        private string _measurementEmissionAddr;
        [Column]
        public string MeasurementEmissionAddr
        {
            get
            {
                return _measurementEmissionAddr;
            }
            set
            {
                if (_measurementEmissionAddr != value)
                {
                    NotifyPropertyChanging("MeasurementEmissionAddr");
                    _measurementEmissionAddr = value;
                    NotifyPropertyChanged("MeasurementEmissionAddr");
                }
            }
        }

        private string _measurementHeight;
        [Column]
        public string MeasurementHeight
        {
            get
            {
                return _measurementHeight;
            }
            set
            {
                if (_measurementHeight != value)
                {
                    NotifyPropertyChanging("MeasurementHeight");
                    _measurementHeight = value;
                    NotifyPropertyChanged("MeasurementHeight");
                }
            }
        }

        private string _measurementRelativeHeight;
        [Column]
        public string MeasurementRelativeHeight
        {
            get
            {
                return _measurementRelativeHeight;
            }
            set
            {
                if (_measurementRelativeHeight != value)
                {
                    NotifyPropertyChanging("MeasurementRelativeHeight");
                    _measurementRelativeHeight = value;
                    NotifyPropertyChanged("MeasurementRelativeHeight");
                }
            }
        }

        private string _measurementDistance;
        [Column]
        public string MeasurementDistance
        {
            get
            {
                return _measurementDistance;
            }
            set
            {
                if (_measurementDistance != value)
                {
                    NotifyPropertyChanging("MeasurementDistance");
                    _measurementDistance = value;
                    NotifyPropertyChanged("MeasurementDistance");
                }
            }
        }

        private string _measurementDir1;
        [Column]
        public string MeasurementDir1
        {
            get
            {
                return _measurementDir1;
            }
            set
            {
                if (_measurementDir1 != value)
                {
                    NotifyPropertyChanging("MeasurementDir1");
                    _measurementDir1 = value;
                    NotifyPropertyChanged("MeasurementDir1");
                }
            }
        }

        private string _measurementDir2;
        [Column]
        public string MeasurementDir2
        {
            get
            {
                return _measurementDir2;
            }
            set
            {
                if (_measurementDir2 != value)
                {
                    NotifyPropertyChanging("MeasurementDir2");
                    _measurementDir2 = value;
                    NotifyPropertyChanged("MeasurementDir2");
                }
            }
        }

        private string _measurementEmissionDes1;
        [Column]
        public string MeasurementEmissionDes1
        {
            get
            {
                return _measurementEmissionDes1;
            }
            set
            {
                if (_measurementEmissionDes1 != value)
                {
                    NotifyPropertyChanging("MeasurementEmissionDes1");
                    _measurementEmissionDes1 = value;
                    NotifyPropertyChanged("MeasurementEmissionDes1");
                }
            }
        }

        private string _measurementEmissionDes2;
        [Column]
        public string MeasurementEmissionDes2
        {
            get
            {
                return _measurementEmissionDes2;
            }
            set
            {
                if (_measurementEmissionDes2 != value)
                {
                    NotifyPropertyChanging("MeasurementEmissionDes2");
                    _measurementEmissionDes2 = value;
                    NotifyPropertyChanged("MeasurementEmissionDes2");
                }
            }
        }

        private string _measurementEmissionColor1;
        [Column]
        public string MeasurementEmissionColor1
        {
            get
            {
                return _measurementEmissionColor1;
            }
            set
            {
                if (_measurementEmissionColor1 != value)
                {
                    NotifyPropertyChanging("MeasurementEmissionColor1");
                    _measurementEmissionColor1 = value;
                    NotifyPropertyChanged("MeasurementEmissionColor1");
                }
            }
        }

        private string _measurementEmissionColor2;
        [Column]
        public string MeasurementEmissionColor2
        {
            get
            {
                return _measurementEmissionColor2;
            }
            set
            {
                if (_measurementEmissionColor2 != value)
                {
                    NotifyPropertyChanging("MeasurementEmissionColor2");
                    _measurementEmissionColor2 = value;
                    NotifyPropertyChanged("MeasurementEmissionColor2");
                }
            }
        }

        private string _measurementPoint1;
        [Column]
        public string MeasurementPoint1
        {
            get
            {
                return _measurementPoint1;
            }
            set
            {
                if (_measurementPoint1 != value)
                {
                    NotifyPropertyChanging("MeasurementPoint1");
                    _measurementPoint1 = value;
                    NotifyPropertyChanged("MeasurementPoint1");
                }
            }
        }

        private string _measurementPoint2;
        [Column]
        public string MeasurementPoint2
        {
            get
            {
                return _measurementPoint2;
            }
            set
            {
                if (_measurementPoint2 != value)
                {
                    NotifyPropertyChanging("MeasurementPoint2");
                    _measurementPoint2 = value;
                    NotifyPropertyChanged("MeasurementPoint2");
                }
            }
        }

        private string _measurementBgDes1;
        [Column]
        public string MeasurementBgDes1
        {
            get
            {
                return _measurementBgDes1;
            }
            set
            {
                if (_measurementBgDes1 != value)
                {
                    NotifyPropertyChanging("MeasurementBgDes1");
                    _measurementBgDes1 = value;
                    NotifyPropertyChanged("MeasurementBgDes1");
                }
            }
        }

        private string _measurementBgDes2;
        [Column]
        public string MeasurementBgDes2
        {
            get
            {
                return _measurementBgDes2;
            }
            set
            {
                if (_measurementBgDes2 != value)
                {
                    NotifyPropertyChanging("MeasurementBgDes2");
                    _measurementBgDes2 = value;
                    NotifyPropertyChanged("MeasurementBgDes2");
                }
            }
        }

        private string _measurementBgColor1;
        [Column]
        public string MeasurementBgColor1
        {
            get
            {
                return _measurementBgColor1;
            }
            set
            {
                if (_measurementBgColor1 != value)
                {
                    NotifyPropertyChanging("MeasurementBgColor1");
                    _measurementBgColor1 = value;
                    NotifyPropertyChanged("MeasurementBgColor1");
                }
            }
        }

        private string _measurementBgColor2;
        [Column]
        public string MeasurementBgColor2
        {
            get
            {
                return _measurementBgColor2;
            }
            set
            {
                if (_measurementBgColor2 != value)
                {
                    NotifyPropertyChanging("MeasurementBgColor2");
                    _measurementBgColor2 = value;
                    NotifyPropertyChanged("MeasurementBgColor2");
                }
            }
        }

        private string _measurementSky1;
        [Column]
        public string MeasurementSky1
        {
            get
            {
                return _measurementSky1;
            }
            set
            {
                if (_measurementSky1 != value)
                {
                    NotifyPropertyChanging("MeasurementSky1");
                    _measurementSky1 = value;
                    NotifyPropertyChanged("MeasurementSky1");
                }
            }
        }

        private string _measurementSky2;
        [Column]
        public string MeasurementSky2
        {
            get
            {
                return _measurementSky2;
            }
            set
            {
                if (_measurementSky2 != value)
                {
                    NotifyPropertyChanging("MeasurementSky2");
                    _measurementSky2 = value;
                    NotifyPropertyChanged("MeasurementSky2");
                }
            }
        }

        private string _measurementWind1;
        [Column]
        public string MeasurementWind1
        {
            get
            {
                return _measurementWind1;
            }
            set
            {
                if (_measurementWind1 != value)
                {
                    NotifyPropertyChanging("MeasurementWind1");
                    _measurementWind1 = value;
                    NotifyPropertyChanged("MeasurementWind1");
                }
            }
        }

        private string _measurementWind2;
        [Column]
        public string MeasurementWind2
        {
            get
            {
                return _measurementWind2;
            }
            set
            {
                if (_measurementWind2 != value)
                {
                    NotifyPropertyChanging("MeasurementWind2");
                    _measurementWind2 = value;
                    NotifyPropertyChanged("MeasurementWind2");
                }
            }
        }

        private string _measurementWindDir1;
        [Column]
        public string MeasurementWindDir1
        {
            get
            {
                return _measurementWindDir1;
            }
            set
            {
                if (_measurementWindDir1 != value)
                {
                    NotifyPropertyChanging("MeasurementWindDir1");
                    _measurementWindDir1 = value;
                    NotifyPropertyChanged("MeasurementWindDir1");
                }
            }
        }

        private string _measurementWindDir2;
        [Column]
        public string MeasurementWindDir2
        {
            get
            {
                return _measurementWindDir2;
            }
            set
            {
                if (_measurementWindDir2 != value)
                {
                    NotifyPropertyChanging("MeasurementWindDir2");
                    _measurementWindDir2 = value;
                    NotifyPropertyChanged("MeasurementWindDir2");
                }
            }
        }

        private string _measurementTemp1;
        [Column]
        public string MeasurementTemp1
        {
            get
            {
                return _measurementTemp1;
            }
            set
            {
                if (_measurementTemp1 != value)
                {
                    NotifyPropertyChanging("MeasurementTemp1");
                    _measurementTemp1 = value;
                    NotifyPropertyChanged("MeasurementTemp1");
                }
            }
        }

        private string _measurementTemp2;
        [Column]
        public string MeasurementTemp2
        {
            get
            {
                return _measurementTemp2;
            }
            set
            {
                if (_measurementTemp2 != value)
                {
                    NotifyPropertyChanging("MeasurementTemp2");
                    _measurementTemp2 = value;
                    NotifyPropertyChanged("MeasurementTemp2");
                }
            }
        }

        private string _measurementWetTemp;
        [Column]
        public string MeasurementWetTemp
        {
            get
            {
                return _measurementWetTemp;
            }
            set
            {
                if (_measurementWetTemp != value)
                {
                    NotifyPropertyChanging("MeasurementWetTemp");
                    _measurementWetTemp = value;
                    NotifyPropertyChanged("MeasurementWetTemp");
                }
            }
        }

        private string _measurementRh;
        [Column]
        public string MeasurementRh
        {
            get
            {
                return _measurementRh;
            }
            set
            {
                if (_measurementRh != value)
                {
                    NotifyPropertyChanging("MeasurementRh");
                    _measurementRh = value;
                    NotifyPropertyChanged("MeasurementRh");
                }
            }
        }

        private string _measurementResultDetail;
        [Column]
        public string MeasuremenResulttDetail
        {
            get
            {
                return _measurementResultDetail;
            }
            set
            {
                if (_measurementResultDetail != value)
                {
                    NotifyPropertyChanging("MeasurementResultDetail");
                    _measurementResultDetail = value;
                    NotifyPropertyChanged("MeasurementResultDetail");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        // Used to notify the page that a data context property changed
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        // Used to notify the data context that a data context property is about to change
        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }
    }
}
